<template lang="pug">
  div
    s-table(
      v-if="$route.path === '/operative/crm/heartClue'"
      ref="table"
      reqUrl="crm/web/leads/page"
      :column="tableObj.column"
      :queryPropsParams="{ status: 3 }"
      :style="{padding: 0}"
      :filterProps="{ fields: tableObj.searchField }"
    )
      template(slot="name" slot-scope="text, scope") {{text}}({{scope.relationship}})
      template(slot="birthday" slot-scope="text, scope")
        span {{text | dateFilter}}
      template(slot="month" slot-scope="text, scope")
        span {{scope.birthday | monthFilter}}
      template(slot="status" slot-scope="text, scope")
        el-tag(size="mini" :type="text | stautsFilter('type')") {{text | stautsFilter('name')}}
      template(slot="lastFollowRecord" slot-scope="text, scope")
        template(v-if="text")
          p {{text}}
          small.c_secondary 跟进时间:{{scope.lastFollowTime | dateFilter}}
        span(v-else) --
      template(slot="action" slot-scope="text, scope")
        el-link(@click="infoHandle(scope.id)" type="primary") 详情
    router-view(v-else)
</template>
<script>
import { pagerMixin } from '@/mixins'
import { column, seachConfig, statusList } from './config'

export default {
  name: 'HeartClue',
  filters: {
    stautsFilter (val, key) {
      if (!val) {
        return key === 'name' ? '其他' : 'info'
      }
      const status = statusList.find(x => x.id === val?.toString()) || {}
      return status[key] || ''
    }
  },
  mixins: [pagerMixin],
  data () {
    return {
      tableObj: {
        column,
        searchField: seachConfig({})
      }
    }
  },
  methods: {
    getList (flag = false) {
      this.$refs.table.refresh(flag)
    },
    // 跳转详情
    infoHandle (id) {
      this.$router.push({
        path: '/operative/crm/clue/info',
        query: { id }
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.table-operator{
  margin-bottom: 18px
}
::v-deep{
  .tableWrapper{
    padding: 0
  }
}
</style>

